package com.xiaoma.loadbalancer;

import com.alibaba.nacos.api.naming.pojo.Instance;

import java.util.List;

/**
 * @Author: xiaoma
 * @Date: 2021/7/5 19:39
 * @description:
 */
public class RoundRobinLoadBalancer  implements LoadBalancer{
    int index=0;
    @Override
    public Instance select(List<Instance> instances) {
        if(index >= instances.size()) {
            index %= instances.size();
        }
        return instances.get(index++);
    }

}
